%Sintonias de controladores PID
global ZN CHR_sem ITAE
%% Ziegler Nichols
KpZN = 1.2*(tal/(K*theta));
tiZN = 2*theta;
tdZN = 0.5*theta;

ZN = [KpZN; tiZN; tdZN];

%% CHR - servo sem sobrevalor
KpCHR_sem = 0.6*tal/(K*theta);
tiCHR_sem = tal;
tdCHR_sem = 0.5*theta;

CHR_sem = [KpCHR_sem; tiCHR_sem; tdCHR_sem];

%% CHR - servo 20% sobrevalor
KpCHR_20 = 0.7*tal/(K*theta);
tiCHR_20 = 1.357*tal;
tdCHR_20 = 0.473*theta;

CHR_20 = [KpCHR_20; tiCHR_20; tdCHR_20];

%% CC
KpCC = (1.35+0.25*(theta/tal))*tal/(K*theta);
tiCC = theta*( (1.35+0.25*(theta/tal))/(0.54+0.33*(theta/tal)) );
tdCC = (0.5*theta)/(1.35+0.25*(theta/tal));

CC = [KpCC; tiCC; tdCC];

%% MIE ITAE servo
A = 0.965;
B = -0.850;
C = 0.796;
D = -0.147;
E = 0.308;
F = 0.929;
KpITAE = 1/K*(A*(theta/tal)^B);
tiITAE = tal/(C+D*(theta/tal));
tdITAE = tal*(E*(theta/tal)^F);

ITAE = [KpITAE; tiITAE; tdITAE];

Pr = ZN(1); In = Pr/ZN(2); De = Pr*ZN(3);
% Pr = CHR_sem(1); In = Pr/CHR_sem(2); De = Pr*CHR_sem(3);
% Pr = ITAE(1); In = Pr/ITAE(2); De = Pr*ITAE(3);